package car.aistar.service.impl;

import car.aistar.dao.PriceCutDao;
import car.aistar.entity.PriceCut;
import car.aistar.service.PriceCutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (PriceCut)表服务实现类
 *
 * @author makejava
 * @since 2020-10-03 16:46:14
 */
@Service("priceCutService")

public class PriceCutServiceImpl implements PriceCutService {
    @Resource
    private PriceCutDao priceCutDao;

    @Override
    public PriceCut queryByUId (Long uid, Long cid){
        return priceCutDao.queryByUId(uid,cid);
    }

    @Override
    public List<PriceCut> queryByCId (Long id){
        return priceCutDao.queryByCId(id);
    }

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PriceCut queryById(Long id) {
        return this.priceCutDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<PriceCut> queryAllByLimit(int offset, int limit) {
        return this.priceCutDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param priceCut 实例对象
     * @return 实例对象
     */
    @Override
    public PriceCut insert(PriceCut priceCut) {
        this.priceCutDao.insert(priceCut);
        return priceCut;
    }

    /**
     * 修改数据
     *
     * @param priceCut 实例对象
     * @return 实例对象
     */
    @Override
    public PriceCut update(PriceCut priceCut) {
        this.priceCutDao.update(priceCut);
        return this.queryById(priceCut.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.priceCutDao.deleteById(id) > 0;
    }

    @Override
    public boolean deleteById1(Long userId, Long carTd) {
        return this.priceCutDao.deleteById1(userId,carTd) > 0;
    }


    @Override
    public List<PriceCut> queryAll(PriceCut priceCut) {
        return this.priceCutDao.queryAll(priceCut);
    }
}